﻿using Reign.Core.MathI32;
using MF = Reign.Core.MathF32;
using Reign.Core;

namespace Reign.Video
{
	public abstract class ViewPortI
	{
		#region Properties
		public Vector2 Location {get; set;}
		public Vector2 Size {get; set;}
		public float AspectRatio {get{return Size.X / (float)Size.Y;}}

		public MF.Vector2 SizeF
		{
			get {return Size.ToFloat2();}
			set {Size = value.ToInt2();}
		}
		#endregion

		#region Constructors
		protected ViewPortI() { }

		protected ViewPortI(int x, int y, int width, int height)
		{
			Set(x, y, width, height);
		}

		protected ViewPortI(Vector2 location, Vector2 size)
		{
			Set(location, size);
		}

		protected ViewPortI(Bound2 bound)
		{
			Set(bound);
		}
		#endregion

		#region Methods
		public void Set(int x, int y, int width, int height)
		{
			Location = new Vector2(x, y);
			Size = new Vector2(width, height);
			SizeF = Size.ToFloat2();
		}

		public void Set(Vector2 location, Vector2 size)
		{
			this.Location = location;
			this.Size = size;
			SizeF = size.ToFloat2();
		}

		public void Set(Bound2 bound)
		{
			Location = new Vector2(bound.Left, bound.Top);
			Size = new Vector2(bound.Right - bound.Left, bound.Bottom - bound.Top);
			SizeF = Size.ToFloat2();
		}

		public abstract void Apply(RenderTargetI renderTarget);
		#endregion
	}
}
